package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.annotation.AutoFIll;
import com.sky.dto.CategoryDTO;
import com.sky.dto.CategoryPageQueryDTO;
import com.sky.entity.Category;
import com.sky.enumeration.OperationType;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;


public interface CategoryMapper {
    Page<Category> page(CategoryPageQueryDTO categoryPageQueryDTO);

    @AutoFIll(OperationType.INSERT)
    @Insert("insert into category values(null, #{type}, #{name}, #{sort}, #{status}, #{createTime}, #{updateTime}, #{createUser}, #{updateUser})")
    void insert(Category Category);

    @Select("select count(*) from dish where category_id = #{type}")
    Integer countByCategoryId(Integer type);

    @Delete("delete from category where id = #{id}")
    void deleteById(Integer id);

    @AutoFIll(OperationType.UPDATE)
    void update(Category category);

    //@Select("select * from category where type = #{type} and status = #{status} ")
    List<Category> listByType(Integer type, Integer status);
}
